<?php

class Session {

	static function init() {
		session_start();
	}

	static function set($name, $value) {
		$_SESSION[$name] = $value;
	}

	static function get($name) {
		return (isset($_SESSION[$name])) ? $_SESSION[$name] : null;
	}

	static function getAndDelete($name) {
		$result = self::get($name);
		self::delete($name);
		return $result;
	}

	static function setSerialized($name, $value) {
		$_SESSION[$name] = serialize($value);
	}

	static function getUnserialized($name) {
		return (isset($_SESSION[$name])) ? unserialize($_SESSION[$name]) : null;
	}

	static function getUnserializedAndDelete($name) {
		$result = self::getUnserialized($name);
		self::delete($name);
		return $result;
	}

	static function delete($name) {
		unset($_SESSION[$name]);
	}

	static function destroy() {
		session_destroy();
	}
}